home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++
- Subject: Re: Forward declarations: why won't they work?
- Date: 23 Mar 1996 13:59:27 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4j103v$ltg@news1.h1.usa.pipeline.com>
- References: <4ivpp0$iut@hustle.rahul.net>
- NNTP-Posting-Host: 38.8.60.7
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 23, 1996 03:05:04 in article <Forward declarations: why won't they
- work?>, 'Theodore Sternberg <strnbrg@rahul.net>' wrote:
-
-
- >Forward class declarations only seem to work sometimes. When they don't
- >work, I get a compiler error to the effect that "struct foo is an
- >imcomplete type". Can anyone tell me what's going on, i.e. when forward
- >class declarations are and are not possible?
- >
- Forward declarations do work -- always (unless you have a broken
- compiler, which is very unlikely). Judging from your wording,
- you are attempting to use a forward-declared class in a manner
- that requires that it be fully defined at the time of usage. No
- can do.
-
- Example:
-
- class Foo; // fwd decl
-
- class Bar
- {
- Foo * pfoo; // OK - it's only a pointer. Compiler can deal with it.
- Foo foo; // illegal. Compiler doesn't know Foo (yet)
-
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-